package String;

import java.util.Arrays;
import java.util.List;

public class _539_MinimumTimeDifference {
    public int findMinDifference(List<String> timePoints) {
        int length = timePoints.size();
        int[] points = new int[length];
        for(int i=0;i<length;i++) {
            String ts = timePoints.get(i);
            String[] time = ts.split(":");
            points[i] = Integer.parseInt(time[0]) * 60 + Integer.parseInt(time[1]);
        }
        Arrays.sort(points);
        int min = Integer.MAX_VALUE;
        for(int i=1;i<points.length;i++) {
            int temp = points[i] - points[i - 1];
            if (temp < min) {
                min = temp;
            }
        }
        int last = 1440 + points[0] - points[points.length - 1];
        if (last < min) {
            min = last;
        }
        return min;
    }
}
